/*
	Copyright (C) 2009 Salil Bhagurkar
	
	This file is part of ViSE
	
	ViSE is free software: you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	ViSE is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.
	
	You should have received a copy of the GNU Lesser General Public License
	along with ViSE.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _ARCH_SHARED_H_
#define _ARCH_SHARED_H_


/*This file completely defines all the functions that an architecture must support for ViSE to be ported to it.*/


int arch_malloc_init();

void arch_configure_interrupt_handler(int irq_no, int (*irq_handler)());
void arch_remove_interrupt_handler(int irq_no);
void arch_configure_timer(int (*timer)(),unsigned long hz);
void arch_remove_timer();

int arch_delay_ms(u32 x);
int arch_delay_us(u32 x);


/*Assembly functions for the scheduler in arch/startup.s*/
extern void arch_switch_task(void *tostack,void **fromstackptr);
extern void arch_switch_task_first(void *tostack,void **fromstackptr);
extern void arch_resume_task(void *tostack);
extern void arch_start_task(void *tostack);

//arch/init.c
void *arch_prepare_task(void *stack_ptr, void *fs_node, void *entry_fn);
struct regs {
	u32 eax,ebx,ecx,edx,esi,edi;
	u16 f; /*f is the int no when calling and returns the flags after returning*/
}__attribute__((packed));
int arch_bios_int(struct regs *regs); //16 bit bios interrupt facility

#define arch_halt() asm volatile ("hlt")
#define arch_allow_interrupts() asm volatile ("sti")
#define arch_block_interrupts() asm volatile ("cli")
#endif
